package com.test.controller;


import com.test.entity.StuAllInfoDto;
import com.test.service.TeaOperatService;
import com.test.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/teaOperat")
public class TeaOperatController extends BaseController{

    @Autowired
    private TeaOperatService teaOperatService;


    //vue查看所有学生信息
    @RequestMapping("/selectAllStuVue")
    @ResponseBody
    public Result selectAllStuVue(StuAllInfoDto stuAllInfoDto){
        Result result = genSuccessResult();
        try {
            List<StuAllInfoDto> stuList = teaOperatService.selectAllStu(stuAllInfoDto,"vue");
            for(int i = 0;i<stuList.size();i++){
                String pidcard = stuList.get(i).getStu_idcard();
                String sixidcard = pidcard.substring(0,12);
                String overidcard = sixidcard+"******";
                stuList.get(i).setStu_idcard(overidcard);
            }
            result .setData(stuList);
        }  catch (Exception e) {
            result = exceptionHandler.handleException(e);
        }
        return result;
    }


    //查看所有学生信息
    @RequestMapping("/selectAllStu")
    @ResponseBody
    public Result selectAllStu(StuAllInfoDto stuAllInfoDto){
        Result result = genSuccessResult();
        try {
            List<StuAllInfoDto> stuList = teaOperatService.selectAllStu(stuAllInfoDto,"未就业");
            for(int i = 0;i<stuList.size();i++){
                String pidcard = stuList.get(i).getStu_idcard();
                String sixidcard = pidcard.substring(0,12);
                String overidcard = sixidcard+"******";
                stuList.get(i).setStu_idcard(overidcard);
            }
            result .setData(stuList);
        }  catch (Exception e) {
        result = exceptionHandler.handleException(e);
    }
        return result;
    }

    //查看所有学生信息
    @RequestMapping("/selectAllStuyi")
    @ResponseBody
    public Result selectAllStuyi(StuAllInfoDto stuAllInfoDto){
        Result result = genSuccessResult();
        try {
            List<StuAllInfoDto> stuList = teaOperatService.selectAllStu(stuAllInfoDto,"已就业");
            for(int i = 0;i<stuList.size();i++){
                String pidcard = stuList.get(i).getStu_idcard();
                String sixidcard = pidcard.substring(0,12);
                String overidcard = sixidcard+"******";
                stuList.get(i).setStu_idcard(overidcard);
            }
            result .setData(stuList);
        }  catch (Exception e) {
            result = exceptionHandler.handleException(e);
        }
        return result;
    }

    //查看所有学生信息
    @RequestMapping("/selectAllStusheng")
    @ResponseBody
    public Result selectAllStusheng(StuAllInfoDto stuAllInfoDto){
        Result result = genSuccessResult();
        try {
            List<StuAllInfoDto> stuList = teaOperatService.selectAllStu(stuAllInfoDto,"升学");
            for(int i = 0;i<stuList.size();i++){
                String pidcard = stuList.get(i).getStu_idcard();
                String sixidcard = pidcard.substring(0,12);
                String overidcard = sixidcard+"******";
                stuList.get(i).setStu_idcard(overidcard);
            }
            result .setData(stuList);
        }  catch (Exception e) {
            result = exceptionHandler.handleException(e);
        }
        return result;
    }

    @RequestMapping("/selectAllStumohu")
    @ResponseBody
    public Result selectAllStumohu(StuAllInfoDto stuAllInfoDto){
        Result result = genSuccessResult();
        try {
            List<StuAllInfoDto> stuList = teaOperatService.selectAllStu(stuAllInfoDto,"");
            for(int i = 0;i<stuList.size();i++){
                String pidcard = stuList.get(i).getStu_idcard();
                String sixidcard = pidcard.substring(0,12);
                String overidcard = sixidcard+"******";
                stuList.get(i).setStu_idcard(overidcard);
            }
            result .setData(stuList);
        }  catch (Exception e) {
            result = exceptionHandler.handleException(e);
        }
        return result;
    }

//查询所有企业的数量
    @RequestMapping("/selectCompCount")
    @ResponseBody
    public int selectCompCount(){
            int result  = teaOperatService.selectCompCount();
        return result;
    }
//查询所有岗位数量
    @RequestMapping("/selectJobCount")
    @ResponseBody
    public int selectJobCount(){
        int result  = teaOperatService.selectJobCount();
        return result;
    }

}
